﻿@using SmartStore.Web.Models.Order;
@model SubmitReturnRequestModel
@{
    Layout = "_Layout";

    Html.AddTitleParts(T("PageTitle.ReturnItems").Text);
}

<div class="page return-request-page">
    <div class="page-title">
        <h1 class="h3">@string.Format(@T("ReturnRequests.Title").Text, Model.OrderId)</h1>
    </div>

    <div class="page-body">
        @if (Model.Result.HasValue())
        {
            <div class="alert alert-success">
                @Model.Result
			</div>
		}
		else
		{
			using (Html.BeginForm())
			{
				Html.HiddenFor(x => x.OrderId);

				<h2 class="h4 font-weight-normal text-muted mb-4">@T("ReturnRequests.SelectProduct(s)")</h2>

				Html.RenderWidget("returnrequest_wish_before");

				<div class="card">
					<div class="cart cart-editable mb-0">
						<div class="cart-head">
							<div class="cart-row">
								<div class="cart-col cart-col-main">
									@T("ReturnRequests.Products.Name")
								</div>
								<div class="cart-col cart-col-price">
									@T("ReturnRequests.Products.Price")
								</div>
								<div class="cart-col cart-col-price">
									@T("ReturnRequests.Products.Quantity")
								</div>
							</div>
						</div>
						<div class="cart-body">
							@foreach (var item in Model.Items)
							{
								<div class="cart-row">
									<div class="cart-col cart-col-main">
										<a class="cart-item-link fs-h6" href="@item.ProductUrl" title="@T("Products.Details")" @Html.LanguageAttributes(item.ProductName)>@item.ProductName</a>
										@if (item.AttributeInfo.HasValue())
										{
											<div class="cart-item-attrs text-muted">
												@Html.Raw(item.AttributeInfo)
											</div>
										}
									</div>
									<div class="cart-col cart-col-price" data-caption="@T("ReturnRequests.Products.Price")">
										<span class="price">@item.UnitPrice</span>
									</div>
									<div class="cart-col cart-col-price" data-caption="@T("ReturnRequests.Products.Quantity")">
										<select name="quantity@(item.Id)" class="form-control">
											@for (int i = 0; i <= item.Quantity; i++)
											{
												<option value="@(i)">@(i)</option>
											}
										</select>
									</div>
								</div>
							}
						</div>
					</div>
				</div>
				
				<div class="mt-5">
					<div class="form-group row">
						<div class="col-md-3">
							@Html.LabelFor(model => model.ReturnReason, new { @class = "col-form-label" })
						</div>
						<div class="col-md-9">
							@Html.DropDownListFor(model => model.ReturnReason, Model.AvailableReturnReasons, new { @class = "form-control return-reasons" })
						</div>
					</div>
					<div class="form-group row">
						<div class="col-md-3">
							@Html.LabelFor(model => model.ReturnAction, new { @class = "col-form-label" })
						</div>
						<div class="col-md-9">
							@Html.DropDownListFor(model => model.ReturnAction, Model.AvailableReturnActions, new { @class = "form-control return-actions" })
						</div>
					</div>
					<div class="form-group row">
						<div class="col-md-3">
							@Html.LabelFor(model => model.Comments, new { @class = "col-form-label" })
						</div>
						<div class="col-md-9">
							@Html.TextAreaFor(model => model.Comments, new { @class = "form-control comment" })
							@Html.ValidationMessageFor(model => model.Comments)
						</div>
					</div>
				</div>

				Html.RenderWidget("returnrequest_wish_after");
			
				<div class="buttons row justify-content-end">
					<div class="col-md-9 mt-3">
						<button type="submit" name="submit-return-request" value="save" class="btn btn-primary btn-lg">
							@T("ReturnRequests.Submit")
						</button>
					</div>
				</div>
            }
        }
    </div>
</div>
